package com.azxc.rapid.plus.user.feign;

import com.azxc.rapid.core.tool.api.R;
import com.azxc.rapid.plus.user.dto.PageFeign;
import com.azxc.rapid.plus.user.entity.UserEntity;
import com.azxc.rapid.plus.user.vo.WestoneBaseMsg;
import com.azxc.rapid.system.user.entity.User;
import com.azxc.rapid.system.user.vo.UserVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.azxc.rapid.plus.system.feign.ISysPlusClient.GET_USER_INFO_ENT_ID;

/**
 * @author linym
 * @className: IUserPlusClient
 * @description:
 * @date 2022/8/23 14:58
 * @version：1.0
 */
@FeignClient(
	value = "rapid-core-plus",
	fallback = IUserPlusClientFallback.class
)
public interface IUserPlusClient {

	String API_PREFIX = "/client-plus";

	String GET_USER_VO = API_PREFIX + "/get-user-vo";
	String GET_USER_LIST_VO = API_PREFIX + "/get-user-list-vo";
	String SELECT_JUDGE_USER = API_PREFIX + "/selectJudgeUser";
	String SELECT_FOOD_DIRECTOR_USER = API_PREFIX + "/selectFoodDirectorUser";
	String SELECT_PRO_EMER_LEADER = API_PREFIX + "/selectProEmerLeader";
	String SELECT_PRO_LEADER = API_PREFIX + "/selectProLeader";
	String SELECT_USER_LIST = API_PREFIX + "/selectUserList";
	String UPDATE_USER_BY_ACCOUNT = API_PREFIX + "/update-user-by-account";
	String RESET_PWD_BY_ACCOUNT = API_PREFIX + "/reset-pwd-by-account";
	String SAVE_ENTERPRISE_USER = API_PREFIX + "/save-enterprise-user";
	String SEND_MSG_TO_WESTONE = API_PREFIX + "/send-msg-to-westone";
	String GET_REGION_CODE = API_PREFIX + "/getRegionCode";
	String SELECT_USER_BY_REGION_CODE = API_PREFIX + "/selectUserByRegionCode";

	String USER_BY_NAME ="/userByName";

	String GET_ENTITY_BY_ID = API_PREFIX + "/get-entity-by-id";

	String USER_PAGE = API_PREFIX + "/user-page";


	String GET_STORAGE_BY_USER_ID = API_PREFIX + "/storage-by-user-id";

	String USER_TRACE_INSTITUTE = API_PREFIX + "/user-trace-institute";
	String GET_USER_INFO_BATCH = API_PREFIX + "/user-info-by-ids";

	String UPDATE_USER_ENT_ID = API_PREFIX + "/updateUserEntId";


	String USER_BY_REGION_CODE = API_PREFIX + "/user/by/region/code";


	/**
	 * 获取当前登录用户的信息-包括行政区域，行政区域级别
	 * @return
	 */
	@GetMapping(GET_USER_VO)
	R<UserVO> getUserInfo();

	/**
	 * 获取当前登录人所属部门下的人员列表
	 * @return
	 */
	@GetMapping(GET_USER_LIST_VO)
	R<List<UserVO>> getUserListInfo(@RequestParam("deptId") String deptId);

	/**
	 * 查询地市应急处干部
	 * @param userId
	 * @return
	 */
	@GetMapping(SELECT_JUDGE_USER)
	R<List<String>> selectJudgeUser(@RequestParam("userId") Long userId);

	/**
	 * 查询省食安办成员
	 * @param userId
	 * @return
	 */
	@GetMapping(SELECT_FOOD_DIRECTOR_USER)
	R<List<String>>selectFoodDirectorUser(@RequestParam("userId") Long userId);

	/**
	 * 查询省局应急处干部
	 * @param userId
	 * @return
	 */
	@GetMapping(SELECT_PRO_EMER_LEADER)
	R<List<String>>selectProEmerLeader(@RequestParam("userId") Long userId);

	/**
	 * 查询省局领导
	 * @param userId
	 * @return
	 */
	@GetMapping(SELECT_PRO_LEADER)
	R<List<String>>selectProLeader(@RequestParam("userId") Long userId);


	/**
	 * 根据传递的ids查询用户集合
	 * @param userIds
	 * @return
	 */
	@GetMapping(SELECT_USER_LIST)
	R<List<User>> userListByIds(@RequestParam("userIds") String userIds);

	/**
	 * 新增企业用户
	 * @param user
	 * @return
	 */
	@RequestMapping(SAVE_ENTERPRISE_USER)
	R<Boolean> saveEnterpriseUser(User user);


	/**
	 * 修改用户名
	 * @return
	 */
	@RequestMapping(UPDATE_USER_BY_ACCOUNT)
	R<Boolean> updateUserByAccount(@RequestParam("oldAccount") String oldAccount,@RequestParam(value = "newAccount",required = false) String newAccount,@RequestParam(value = "newName",required = false) String newName);

	/**
	 * 重置密码
	 * @param account 账户登录用的名称
	 * @return
	 */
	@RequestMapping(RESET_PWD_BY_ACCOUNT)
	R<Boolean> resetPasswordByAccount(@RequestParam("account") String account);


	/**
	 * @className:IUserPlusClient
	 * @methodName: sendMsgToWestone
	 * @description: 发送消息给卫士通，推送到app上
	 * @param:
	 * @return:
	 * @author: linym
	 * @date: 2023/2/3 14:14
	 **/
	@RequestMapping(SEND_MSG_TO_WESTONE)
	R<Boolean> sendMsgToWestoneByMobile(WestoneBaseMsg westoneBaseMsg);


	/**
	 * 获取用户行政区划编码
	 * @return
	 * @author: SQG
	 * @date: 2023/2/13 9:14
	 */
	@GetMapping(GET_REGION_CODE)
	R<String> getRegionCode();

	/**
	 * 根据传递的RegionCode查询用户
	 * @param regionCode
	 * @return列表
	 */
	@GetMapping(SELECT_USER_BY_REGION_CODE)
	R<List<User>> selectUserByRegionCode(@RequestParam("regionCode") String regionCode);

	@GetMapping(USER_BY_NAME)
	R<User> userByName(@RequestParam("userName") String userName,@RequestParam("deptName") String deptName);


	/**
	 * 根据用户id获取企业id,目前只支持1对1，一个用户只能负责一个企业
	 *
	 * @param userId
	 * @return
	 */
	@GetMapping(GET_ENTITY_BY_ID)
	R<UserEntity> getEntityByUser(@RequestParam("userId") String userId);

	@GetMapping(USER_PAGE)
	R<PageFeign<User>> userPage(@RequestParam("current") Integer current,
								@RequestParam("size") Integer size);



	@GetMapping(GET_STORAGE_BY_USER_ID)
	R<List<Long>> getStorageByUserId();

	@GetMapping(USER_TRACE_INSTITUTE)
	R<PageFeign<User>> userTraceInstitute(@RequestParam("current") Integer current,
										  @RequestParam("size") Integer size);



	/**
	 * 根据id批量获取用户信息
	 *
	 * @param userIds 用户id集合
	 * @return
	 */
	@GetMapping(GET_USER_INFO_BATCH)
	R<List<User>> userInfoBatch(@RequestParam("ids") String userIds);

	@PostMapping(UPDATE_USER_ENT_ID)
	void updateUserEntId(@RequestBody User data);



	@GetMapping(USER_BY_REGION_CODE)
	R<List<User>> getUserByRegionCode(@RequestParam String regionCodes);
}
